<template>
  <el-scrollbar height="650px">
    <el-form :inline="true">
      <el-form-item label-width="68px" label="用户名称">
        <el-input v-model="souform.name" placeholder="请输入用户名称" />
      </el-form-item>
      <el-form-item label-width="68px" label="手机号码">
        <el-input v-model="souform.phone" placeholder="请输入用户名称" />
      </el-form-item>
      <el-form-item>
        <el-button type="primary">搜索</el-button>
        <el-button>重置</el-button>
      </el-form-item>
    </el-form>
  <div class="el-form1">
    <el-button @click="is=!is;add()" type="primary" plain>添加用户</el-button>
    <el-button @click="is=!is" type="success" plain>批量取消授权</el-button>
  </div>
  <el-table
      :data="tableData"
      style="width: 100%"
      :header-cell-style="{background:'#F5F7FA'}"
  >
    <el-table-column align="center" type="selection" width="55" />
    <el-table-column align="center" property="name" label="用户名称" >
    </el-table-column>
    <el-table-column align="center" property="userno" label="工 号"  />
    <el-table-column align="center" property="phone" label="手机号码" />
    <el-table-column align="center" property="address" label="状 态">
      <el-switch v-model="value1" />
    </el-table-column>
    <el-table-column align="center" label="操 作">
      <el-button @click="open()" type="primary" plain>取消授权</el-button>
    </el-table-column>
  </el-table>
  <!--弹出-->
  <el-dialog v-model="dialogFormVisible" title="选择用户">
    <div class="el-form1">
      <div class="findtitle">
        用户名称
      </div>
      <div style="width: 250px">
        <el-input
            v-model="souform.name"
            placeholder="请输入用户名称"
            :suffix-icon="Search"
        />
      </div>
      <div class="findtitle">
        手机号码
      </div>
      <div style="width: 250px">
        <el-input
            v-model="souform.phone"
            placeholder="请输入手机号码"
            :suffix-icon="Search"
        />
      </div>
      <div>
        <el-button type="primary">搜索</el-button>
      </div>
      <div>
        <el-button>重置</el-button>
      </div>
    </div>
    <el-table :data="userData" style="width: 100%"
              :header-cell-style="{background:'#F5F7FA'}"
    >
      <el-table-column align="center" type="selection" width="55" />
      <el-table-column align="center" prop="username" label="用户名" width="180" />
      <el-table-column align="center" prop="phone" label="手 机" width="180" />
      <el-table-column align="center" prop="userno" label="工 号" width="180"/>
      <el-table-column align="center" property="address" label="状 态" show-overflow-tooltip>
        <el-switch v-model="value1" />
      </el-table-column>
    </el-table>
    <template #footer>
      <span class="dialog-footer">
        <el-button @click="resetForm(bookForm)">取消</el-button>
        <el-button type="primary" @click="saveBook(bookForm)">确定</el-button>
      </span>
    </template>
  </el-dialog>
  </el-scrollbar>
</template>

<script lang="ts" setup>
import { Search } from '@element-plus/icons-vue'
import {reactive} from "vue";
import {ref} from "@vue/reactivity";
import {ElMessageBox,ElMessage} from "element-plus";
import type {FormInstance} from 'element-plus'
//新增,隐藏层
const dialogFormVisible=ref(false)
const add=async (formEl: FormInstance | undefined)=>{
  dialogFormVisible.value=true;
  console.log(1)
}
//搜索表单
const souform = reactive({
  name: '',
  phone: '',
})
//用户状态
const value1 = ref(true)
//table该角色拥有的用户表格
const tableData = [
  {
    date: '1',
    name: 'Tom',
    address: '全部数据权限',
    userno:'234567',
    phone:'234',
  }
]
//所有用户data
const userData=[
  {
    username:'cjl',
    phone:'234567',
    userno:'234567'
  }
]
//确认取消授权
const open = () => {
  ElMessageBox.confirm(
      '确认要取消该用户"admin"角色吗？',
      '系统提示',
      {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
      }
  )
      .then(() => {
        ElMessage({
          type: 'success',
          message: '取消授权成功！',
        })
      })
      .catch(() => {
        ElMessage({
          type: 'info',
          message: 'Delete canceled',
        })
      })
}
</script>

<style>
.el-form1{
  display: flex;text-align: center;margin-bottom: 20px;
}
.el-form1 div{
  margin-right: 5px;
}
.findtitle{
  text-align: center;
  line-height: 30px;
}
.el-dialog{
  width: 810px;
}
</style>